package com.swxy.service.Impl;

import com.swxy.dao.UserDao;
import com.swxy.pojo.User;
import com.swxy.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service

public class LoginServiceImpl implements LoginService {
    @Autowired
    private UserDao userDao;


    @Override
    public User login(String phone, String password) {
//        return userDao.login(phone,password);

        List<User> list=userDao.login(phone,password);
        if(list==null||list.isEmpty()) {
            System.out.println("不匹配");
            return null;
        }else {
            System.out.println(list.get(0));
            return list.get(0);
        }
    }
//
//    @Override
//    public User getUserByUserName(User user) {
//        List<User> list=userDao.getUserByUserName(user);
//        if(list==null || list.isEmpty()) {
//            return null;
//        }
//        return list.get(0);
//    }
//
    @Override
    public int addUser(User user) {
        return userDao.addUser(user);

    }
//

//
    @Override
    public User checkReg(String userName) {
        return userDao.checkReg(userName);

    }

    @Override
    public int insert(User sysUser) {
        return userDao.insert(sysUser);

    }

    @Override
    public User selectById(int id) {
        return userDao.selectById(id);

    }






    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

}
